/**
 * File    : LocaleSwitcher.java
 * Created : 2008-10-16
 * By      : LuHuiguo
 */
package com.luhuiguo.tapestry.components;

import java.util.Locale;

import org.apache.tapestry5.SelectModel;
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.ValueEncoder;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.services.PersistentLocale;

import com.luhuiguo.tapestry.model.LocaleEncoder;
import com.luhuiguo.tapestry.model.LocaleSelectModel;

/**
 * @author LuHuiguo
 * @version $Id: LocaleSwitcher.java 6 2008-10-18 06:09:49Z LuHuiguo $
 * 
 */
public class LocaleSwitcher {

	@Inject
	private PersistentLocale persistentLocale;

	@Inject
	@Symbol(SymbolConstants.SUPPORTED_LOCALES)
	private String supportedLocales;

	public Locale getSelectedLocale() {
		return persistentLocale.get();
	}

	public void setSelectedLocale(Locale selectedLocale) {
		persistentLocale.set(selectedLocale);
	}

	public SelectModel getLocaleModel() {
		return new LocaleSelectModel(supportedLocales);
	}

	public ValueEncoder<Locale> getLocaleEncoder() {
		return new LocaleEncoder();
	}
}